if (!session) {
  session = request.getSession(true);
}

if (!session.counter) {
  session.counter = 1
}

//out << """{"name": "MC", "counter": ${session.counter}}"""
json.people { 
	person {
	     firstName 'Tim'
	     lastName 'Yates'
	     // Named arguments are valid values for objects too
	     address(
	         city: 'Manchester',
	         country: 'UK',
	         zip: 'M1 2AB',
	     )
	     living true
	     eyes 'left', 'right'
	     counter session.counter
	}
}

session.counter = session.counter + 1

response.setContentType("application/json")